package route

import (
	"github.com/gin-gonic/gin"
	"nt-order/common"
	"nt-order/model"
	"nt-order/route/form"
	"nt-order/service"
)

func Index(context *gin.Context) {
	var f form.IndexForm
	if err := context.ShouldBind(&f); err != nil {
		common.FailJson(context, 404, err.Error())
		return
	}

	val, exists := context.Get("userInfo")
	var userInfo model.UserInfo
	if exists {
		userInfo = val.(model.UserInfo)
	} else {
		userInfo = model.UserInfo{}
	}
	f.StaffId = userInfo.Staff_id
	f.StaffName = userInfo.Staff_name
    //fmt.Println(f)
	go func() {
		new(service.OrderDataExportLogic).OrderDataExport(&f)
	}()

	context.JSON(200, gin.H{"code": 0, "msg": "SUCCESS"})
}

func Home(context *gin.Context) {
	context.JSON(200, gin.H{"code": 0, "msg": "SUCCESS"})
}

func Test(context *gin.Context) {
	context.JSON(200, gin.H{"code": 0, "msg": "SUCCESS"})
}
